#ifndef _PERSONLIST_H 
#define _PERSONLIST_H

#include<string>
#include<iostream>

using namespace std;

// base class Person
class Person {
  public:
    Person(int identity, string name, string sex);
    virtual void Display()=0;
    int m_identity;
    string m_name;
    string m_sex;
};

// Employee class
class Employee: public Person {
  public:
    Employee(int identity, string name, string sex, string dept);
    void Display();
  private:
    string m_dept;
};

// Teacher class
class Teacher: public Person {
  public:
    Teacher(int identity, string name, string sex, string subject);
    void Display();
  private:
    string m_subject;
};

// Student class
class Student: public Person {
  public:
    Student(int identity, string name, string sex, int grade);
    void Display();
  private:
    int m_grade;
};

class PersonList;

class Node {
    friend class PersonList;
  public:
    Node(Person *data);
  private:
    Person *m_data;
    Node *m_next;
};

class PersonList {
  public:
    PersonList();
    // 插入
    void Insert(Person *newNode);
    // 删除
    void Delete(int identity);
    // 遍历
    void Print();
    void Find(int identity);
  private:
    int m_length;
    Node *m_head;
    Node *m_tail;
};


#endif
